﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新增工作站</title>
    <link href="~/libs/layui-v2.9.17/layui/css/layui.css" rel="stylesheet" />
    <script src="~/libs/layui-v2.9.17/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">工作站编码</label>
            <div class="layui-input-block" style="width:400px">
                <input type="text" name="workstationCode" id="workstationCode" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                <input type="checkbox" name="autoGenerate" lay-skin="switch" lay-text="自动生成" lay-filter="autoGenerate" style="display: inline-block; margin-left: 10px;">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">工作站名称</label>
            <div class="layui-input-block">
                <input type="text" name="workstationName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">工作站地点</label>
            <div class="layui-input-block">
                <input type="text" name="workstationAddress" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所在车间</label>
            <div class="layui-input-block">
                <select name="workshopId" lay-verify="required">
                    <option value="0">请选择</option>
                    <option value="3">车间1</option>
                    <option value="4">车间2</option>
                    <option value="5">车间3</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属工序</label>
            <div class="layui-input-block">
                <select name="processId" lay-verify="required">
                    <option value="0">请选择</option>
                    <option value="1">制造发动机</option>
                    <option value="2">制造机翼</option>
                    <option value="3">制造机身</option>
                    <option value="4">制造电池</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="radio" name="enableFlag" value="是" title="是" checked>
                <input type="radio" name="enableFlag" value="否" title="否">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="remark"></textarea>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        layui.use('form', function () {
            const form = layui.form;
            form.render();
            // 生成随机代码
            function generateRandomCode() {
                return Math.random().toString(36).substr(2, 10).toUpperCase();
            }
            // 自动生成客户编码
            form.on('switch(autoGenerate)', function (data) {
                if (data.elem.checked) {
                    $('#workstationCode').val(generateRandomCode());
                } else {
                    $('#workstationCode').val('');
                }
            });
        });
    </script>
</body>
</html>
